﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Vaffanculo.Data.Interfaces
{
    /// <summary>
    /// Repository Interface defines the base
    /// functionality required by all Repositories.
    /// </summary>
    /// <typeparam name="TEntity">
    /// The entity type that requires a Repository.
    /// </typeparam>
    public interface IRepository<TEntity>
    {        
        // CRUD methods
        void Add(TEntity entity);       
        void Delete(TEntity entity);
        void DeleteByFilter(Expression<Func<TEntity, bool>> filter);
                
        int Save();
        // Count rows
        int GetCount();        
        
        // Lists
        IList<TEntity> GetAll();
        IList<TEntity> GetByFilter(Expression<Func<TEntity, bool>> filter);

        IQueryable<TEntity> AsQueryable();
        IQueryable<TEntity> AsQueryableByFilter(Expression<Func<TEntity, bool>> filter);

        IEnumerable<TEntity> GetAllIEnumerable();
        //IEnumerable<TEntity> GetByFilter(Func<TEntity, bool> predicate);
        IEnumerable<TEntity> GetIEnumerableByFilter(Expression<Func<TEntity, bool>> filter);
        
        // Methods to get Entity
        //TEntity GetById(object id);
        TEntity GetSingle(Expression<Func<TEntity, bool>> filter);
        TEntity GetFirst(Expression<Func<TEntity, bool>> filter);
        //TEntity First(Func<TEntity, bool> predicate);        

    }
}
